home *** CD-ROM | disk | FTP | other *** search
/ Net Connect / NetConnect - Version 1.iso / mui / developer / c / examples / mui-demo.c < prev    next >
C/C++ Source or Header  |  1997-02-11  |  28KB  |  657 lines

  1. /*
  2. **          C Source Code For The MUI Demo Program
  3. **          --------------------------------------
  4. **
  5. **             written 1992-95 by Stefan Stuntz
  6. **
  7. ** Even if it doesn't look so, all of the code below is pure C,
  8. ** just a little bit enhanced with some MUI specific macros.
  9. **
  10. ** NOTE: This demo shows a few MUI techniques (like Return IDs)
  11. ** that are a little outdated. Be sure to also check the other
  12. ** demonstration programs for more object oriented GUI design!
  13. */
  14.  
  15. #include "demo.h"
  16.  
  17.  
  18. /*
  19. ** A little array definition:
  20. */
  21.  
  22. static const char *LVT_Brian[] =
  23. {
  24. "Cheer up, Brian. You know what they say.",
  25. "Some things in life are bad,",
  26. "They can really make you mad.",
  27. "Other things just make you swear and curse.",
  28. "When you're chewing on life's grissle,",
  29. "Don't grumble, give a whistle.",
  30. "And this'll help things turn out for the best,",
  31. "And...",
  32. "",
  33. "Always look on the bright side of life",
  34. "Always look on the light side of life",
  35. "",
  36. "If life seems jolly rotten,",
  37. "There's something you've forgotten,",
  38. "And that's to laugh, and smile, and dance, and sing.",
  39. "When you're feeling in the dumps,",
  40. "Don't be silly chumps,",
  41. "Just purse your lips and whistle, that's the thing.",
  42. "And...",
  43. "",
  44. "Always look on the bright side of life, come on!",
  45. "Always look on the right side of life",
  46. "",
  47. "For life is quite absurd,",
  48. "And death's the final word.",
  49. "You must always face the curtain with a bow.",
  50. "Forget about your sin,",
  51. "Give the audience a grin.",
  52. "Enjoy it, it's your last chance anyhow,",
  53. "So...",
  54. "",
  55. "Always look on the bright side of death",
  56. "Just before you draw your terminal breath.",
  57. "",
  58. "Life's a piece of shit,",
  59. "When you look at it.",
  60. "Life's a laugh, and death's a joke, it's true.",
  61. "You'll see it's all a show,",
  62. "Keep 'em laughing as you go,",
  63. "Just remember that the last laugh is on you.",
  64. "And...",
  65. "",
  66. "Always look on the bright side of life !",
  67. "",
  68. "...",
  69. NULL,
  70. };
  71.  
  72.  
  73.  
  74. /*
  75. ** Convetional GadTools NewMenu structure, a memory
  76. ** saving way of definig menus.
  77. */
  78.  
  79. #define ID_ABOUT  1
  80. #define ID_NEWVOL 2
  81. #define ID_NEWBRI 3
  82.  
  83. struct NewMenu Menu[] =
  84. {
  85.     { NM_TITLE, "Project"  , 0 ,0,0,(APTR)0            },
  86.     { NM_ITEM , "About..." ,"?",0,0,(APTR)ID_ABOUT     },
  87.     { NM_ITEM , NM_BARLABEL, 0 ,0,0,(APTR)0            },
  88.     { NM_ITEM , "Quit"     ,"Q",0,0,(APTR)MUIV_Application_ReturnID_Quit },
  89.     { NM_END  , NULL       , 0 ,0,0,(APTR)0            },
  90. };
  91.  
  92.  
  93. /*
  94. ** Here are all the little info texts
  95. ** that appear at the top of each demo window.
  96. */
  97.  
  98. static const char IN_Master[]    = "\tWelcome to the MUI demonstration program. \
  99. This little toy will show you how easy it is to create graphical user interfaces \
  100. with MUI and how powerful the results are.\n\tMUI is based on BOOPSI, Amiga's \
  101. basic object oriented programming system. For details about programming, see the \
  102. 'ReadMe' file and the documented source code of this demo. Only one thing so far: \
  103. it's really easy!\n\tNow go on, click around and watch this demo. Or use your \
  104. keyboard (TAB, Return, Cursor-Keys) if you like that better. Hint: play \
  105. around with the MUI preferences program and customize every pixel to fit \
  106. your personal taste.";
  107.  
  108. static const char IN_Notify[]    = "\tMUI objects communicate with each other \
  109. with the aid of a notifcation system. This system is frequently used in every \
  110. MUI application. Binding an up and a down arrow to a prop gadget e.g. makes up \
  111. a scrollbar, binding a scrollbar to a list makes up a listview. You can also \
  112. bind windows to buttons, thus the window will be opened when the button is \
  113. pressed.\n\tRemember: The main loop of this demo program simply consists of \
  114. a Wait(). Once set up, MUI handles all user actions concerning the GUI \
  115. automatically.";
  116.  
  117. static const char IN_Frames[]    = "\tEvery MUI object can have a surrounding \
  118. frame. Several types are available, all adjustable with the preferences program.";
  119.  
  120. static const char IN_Images[]    = "\tMUI offers a vector image class, that allows \
  121. images to be zoomed to any dimension. Every MUI image is transformed to match the \
  122. current screens colors before displaying.\n\tThere are several standard images for \
  123. often used GUI components (e.g. Arrows). These standard images can be defined via \
  124. the preferences program.";
  125.  
  126. static const char IN_Groups[]    = "\tGroups are very important for MUI. Their \
  127. combinations determine how the GUI will look. A group may contain any number of \
  128. child objects, which are positioned either horizontal or vertical.\n\tWhen a \
  129. group is layouted, the available space is distributed between all of its \
  130. children, depending on their minimum and maximum dimensions and on their \
  131. weight.\n\tOf course, the children of a group may be other groups. There \
  132. are no restrictions.";
  133.  
  134. static const char IN_Backfill[]  = "\tEvery object can have its own background, \
  135. if it wants to. MUI offers several standard backgrounds (e.g. one of the DrawInfo \
  136. pens or one of the rasters below).\nThe prefs program allows defining a large number \
  137. of backgrounds... try it!";
  138.  
  139. static const char IN_Listviews[] = "\tMUI's list class is very flexible. A list can \
  140. be made up of any number of columns containing formatted text or even images. Several \
  141. subclasses of list class (e.g. a directory class and a volume class) are available. \
  142. All MUI lists have the capability of multi selection, just by setting a single \
  143. flag.\n\tThe small info texts at the top of each demo window are made with floattext \
  144. class. This one just needs a character string as input and formats the text according \
  145. to its width.";
  146.  
  147. static const char IN_Cycle[]     = "\tCycle gadgets, radios buttons and simple lists \
  148. can be used to let the user pick exactly one selection from a list of choices. In this \
  149. example, all three possibilities are shown. Of course they are connected via notification, \
  150. so every object will immediately be notified and updated when necessary.";
  151.  
  152. static const char IN_String[]    = "\tOf course, MUI offers a standard string gadget class \
  153. for text input. The gadget in this example is attached to the list, you can control the \
  154. list cursor from within the gadget.";
  155.  
  156.  
  157. /*
  158. ** This are the entries for the cycle gadgets and radio buttons.
  159. */
  160.  
  161. static const char *CYA_Computer[] = { "Amiga 500","Amiga 600","Amiga 1000 :)","Amiga 1200","Amiga 2000","Amiga 3000","Amiga 4000", "Amiga 4000T", "Atari ST :(", NULL };
  162. static const char *CYA_Printer[]  = { "HP Deskjet","NEC P6","Okimate 20",NULL };
  163. static const char *CYA_Display[]  = { "A1081","NEC 3D","A2024","Eizo T660i",NULL };
  164.  
  165.  
  166. /*
  167. ** Some Macros to make my life easier and the actual source
  168. ** code more readable.
  169. */
  170.  
  171. #define List(ftxt)               ListviewObject, MUIA_Weight, 50, MUIA_Listview_Input, FALSE, MUIA_Listview_List,\
  172.                                  FloattextObject, MUIA_Frame, MUIV_Frame_ReadList, MUIA_Background, MUII_ReadListBack, MUIA_Floattext_Text, ftxt, MUIA_Floattext_TabSize, 4, MUIA_Floattext_Justify, TRUE, End, End
  173. #define DemoWindow(name,id,info) WindowObject, MUIA_Window_Title, name, MUIA_Window_ID, id, WindowContents, VGroup, Child, List(info)
  174. #define Image(nr)                ImageObject, MUIA_Image_Spec, nr, End
  175. #define ScaledImage(nr,s,x,y)    ImageObject, MUIA_Image_Spec, nr, MUIA_FixWidth, x, MUIA_FixHeight, y, MUIA_Image_FreeHoriz, TRUE, MUIA_Image_FreeVert, TRUE, MUIA_Image_State, s, End
  176. #define HProp                    PropObject, PropFrame, MUIA_Prop_Horiz, TRUE, MUIA_FixHeight, 8, MUIA_Prop_Entries, 111, MUIA_Prop_Visible, 10, End
  177. #define VProp                    PropObject, PropFrame, MUIA_Prop_Horiz, FALSE, MUIA_FixWidth , 8, MUIA_Prop_Entries, 111, MUIA_Prop_Visible, 10, End
  178.  
  179.  
  180. /*
  181. ** For every object we want to refer later (e.g. for notification purposes)
  182. ** we need a pointer. These pointers do not need to be static, but this
  183. ** saves stack space.
  184. */
  185.  
  186. static APTR AP_Demo;
  187. static APTR WI_Master,WI_Frames,WI_Images,WI_Notify,WI_Listviews,WI_Groups,WI_Backfill,WI_Cycle,WI_String;
  188. static APTR BT_Notify,BT_Frames,BT_Images,BT_Groups,BT_Backfill,BT_Listviews,BT_Cycle,BT_String,BT_Quit;
  189. static APTR PR_PropA,PR_PropH,PR_PropV,PR_PropL,PR_PropR,PR_PropT,PR_PropB;
  190. static APTR LV_Volumes,LV_Directory,LV_Computer,LV_Brian;
  191. static APTR CY_Computer,CY_Printer,CY_Display;
  192. static APTR MT_Computer,MT_Printer,MT_Display;
  193. static APTR ST_Brian;
  194. static APTR GA_Gauge1,GA_Gauge2,GA_Gauge3;
  195. static APTR BP_Wheel;
  196.  
  197.  
  198. /*
  199. ** This is where it all begins...
  200. */
  201.  
  202. int main(int argc,char *argv[])
  203. {
  204.  
  205. /*
  206. ** The init() functions is define in demos.h and does nothing
  207. ** but open "muimaster.library".
  208. */
  209.  
  210.     init();
  211.  
  212.  
  213. /*
  214. ** Every MUI application needs an application object
  215. ** which will hold general information and serve as
  216. ** a kind of anchor for user input, ARexx functions,
  217. ** commodities interface, etc.
  218. **
  219. ** An application may have any number of SubWindows
  220. ** which can all be created in the same call or added
  221. ** later, according to your needs.
  222. **
  223. ** Note that creating a window does not mean to
  224. ** open it, this will be done later by setting
  225. ** the windows open attribute.
  226. */
  227.  
  228.     AP_Demo = ApplicationObject,
  229.         MUIA_Application_Title         , "MUI-Demo",
  230.         MUIA_Application_Version       , "$VER: MUI-Demo 19.5 (11.02.97)",
  231.         MUIA_Application_Copyright     , "Copyright ©1992-95, Stefan Stuntz",
  232.         MUIA_Application_Author        , "Stefan Stuntz",
  233.         MUIA_Application_Description   , "Demonstrate the features of MUI.",
  234.         MUIA_Application_Base          , "MUIDEMO",
  235.         MUIA_Application_Menustrip     , MUI_MakeObject(MUIO_MenustripNM,Menu,0),
  236.  
  237.         SubWindow,
  238.             WI_String = DemoWindow("String",MAKE_ID('S','T','R','G'),IN_String),
  239.                 Child, LV_Brian = ListviewObject,
  240.                     MUIA_Listview_Input, TRUE,
  241.                     MUIA_Listview_List, ListObject, InputListFrame, End,
  242.                     End,
  243.                 Child, ST_Brian = StringObject, StringFrame, End,
  244.                 End,
  245.             End,
  246.  
  247.         SubWindow,
  248.             WI_Cycle = DemoWindow("Cycle Gadgets & RadioButtons",MAKE_ID('C','Y','C','L'),IN_Cycle),
  249.                 Child, HGroup,
  250.                     Child, MT_Computer = Radio("Computer:",CYA_Computer),
  251.                     Child, VGroup,
  252.                         Child, MT_Printer = Radio("Printer:",CYA_Printer),
  253.                         Child, VSpace(0),
  254.                         Child, MT_Display = Radio("Display:",CYA_Display),
  255.                         End,
  256.                     Child, VGroup,
  257.                         Child, ColGroup(2), GroupFrameT("Cycle Gadgets"),
  258.                             Child, KeyLabel1("Computer:",'c'), Child, CY_Computer = KeyCycle(CYA_Computer,'c'),
  259.                             Child, KeyLabel1("Printer:" ,'p'), Child, CY_Printer  = KeyCycle(CYA_Printer ,'p'),
  260.                             Child, KeyLabel1("Display:" ,'d'), Child, CY_Display  = KeyCycle(CYA_Display ,'d'),
  261.                             End,
  262.                         Child, LV_Computer =    ListviewObject,
  263.                             MUIA_Listview_Input, TRUE,
  264.                             MUIA_Listview_List, ListObject, InputListFrame, End,
  265.                             End,
  266.                         End,
  267.                     End,
  268.                 End,
  269.             End,
  270.  
  271.         SubWindow,
  272.             WI_Listviews = DemoWindow("Listviews",MAKE_ID('L','I','S','T'),IN_Listviews),
  273.                 Child, HGroup, GroupFrameT("Dir & Volume List"),
  274.                     Child, LV_Directory = ListviewObject,
  275.                         MUIA_Listview_Input, TRUE,
  276.                         MUIA_Listview_MultiSelect, TRUE,
  277.                         MUIA_Listview_List, DirlistObject, InputListFrame, MUIA_Dirlist_Directory, "ram:", MUIA_List_Title, TRUE, End,
  278.                         End,
  279.                     Child, LV_Volumes = ListviewObject,
  280.                         MUIA_Weight, 20,
  281.                         MUIA_Listview_Input, TRUE,
  282.                         MUIA_Listview_List, VolumelistObject, InputListFrame, MUIA_Dirlist_Directory, "ram:", End,
  283.                         End,
  284.                     End,
  285.                 End,
  286.             End,
  287.  
  288.         SubWindow,
  289.             WI_Notify = DemoWindow("Notifying",MAKE_ID('B','R','C','A'),IN_Notify),
  290.                 Child, HGroup, GroupFrameT("Connections"),
  291.                     Child, GA_Gauge1 = GaugeObject, GaugeFrame, MUIA_Gauge_Horiz, FALSE, MUIA_FixWidth, 16, End,
  292.                     Child, PR_PropL = VProp,
  293.                     Child, PR_PropR = VProp,
  294.                     Child, VGroup,
  295.                         Child, VSpace(0),
  296.                         Child, PR_PropA = HProp,
  297.                         Child, HGroup,
  298.                             Child, PR_PropH = HProp,
  299.                             Child, PR_PropV = HProp,
  300.                             End,
  301.                         Child, VSpace(0),
  302.                         Child, VGroup, GroupSpacing(1),
  303.                             Child, GA_Gauge2 = GaugeObject, GaugeFrame, MUIA_Gauge_Horiz, TRUE, End,
  304.                             Child, ScaleObject, MUIA_Scale_Horiz, TRUE, End,
  305.                             End,
  306.                         Child, VSpace(0),
  307.                         End,
  308.                     Child, PR_PropT = VProp,
  309.                     Child, PR_PropB = VProp,
  310.                     Child, GA_Gauge3 = GaugeObject, GaugeFrame, MUIA_Gauge_Horiz, FALSE, MUIA_FixWidth, 16, End,
  311.                     End,
  312.                 End,
  313.             End,
  314.  
  315.         SubWindow,
  316.             WI_Backfill = DemoWindow("Backfill",MAKE_ID('B','A','C','K'),IN_Backfill),
  317.                 Child, VGroup, GroupFrameT("Standard Backgrounds"),
  318.                     Child, HGroup,
  319.                         Child, RectangleObject, TextFrame, MUIA_Background, MUII_BACKGROUND            , End,
  320.                      Child, RectangleObject, TextFrame, MUIA_Background, MUII_FILL                  , End,
  321.                      Child, RectangleObject, TextFrame, MUIA_Background, MUII_SHADOW                , End,
  322.                         End,
  323.                     Child, HGroup,
  324.                      Child, RectangleObject, TextFrame, MUIA_Background, MUII_SHADOWBACK            , End,
  325.                      Child, RectangleObject, TextFrame, MUIA_Background, MUII_SHADOWFILL            , End,
  326.                      Child, RectangleObject, TextFrame, MUIA_Background, MUII_SHADOWSHINE           , End,
  327.                         End,
  328.                     Child, HGroup,
  329.                      Child, RectangleObject, TextFrame, MUIA_Background, MUII_FILLBACK              , End,
  330.                      Child, RectangleObject, TextFrame, MUIA_Background, MUII_SHINEBACK             , End,
  331.                      Child, RectangleObject, TextFrame, MUIA_Background, MUII_FILLSHINE             , End,
  332.                         End,
  333.                     End,
  334.                 End,
  335.             End,
  336.  
  337.         SubWindow,
  338.             WI_Groups = DemoWindow("Groups",MAKE_ID('G','R','P','S'),IN_Groups),
  339.                 Child, HGroup, GroupFrameT("Group Types"),
  340.                     Child, HGroup, GroupFrameT("Horizontal"),
  341.                         Child, RectangleObject, TextFrame, End,
  342.                         Child, RectangleObject, TextFrame, End,
  343.                         Child, RectangleObject, TextFrame, End,
  344.                         End,
  345.                     Child, VGroup, GroupFrameT("Vertical"),
  346.                         Child, RectangleObject, TextFrame, End,
  347.                         Child, RectangleObject, TextFrame, End,
  348.                         Child, RectangleObject, TextFrame, End,
  349.                         End,
  350.                     Child, ColGroup(3), GroupFrameT("Array"),
  351.                         Child, RectangleObject, TextFrame, End,
  352.                         Child, RectangleObject, TextFrame, End,
  353.                         Child, RectangleObject, TextFrame, End,
  354.                         Child, RectangleObject, TextFrame, End,
  355.                         Child, RectangleObject, TextFrame, End,
  356.                         Child, RectangleObject, TextFrame, End,
  357.                         Child, RectangleObject, TextFrame, End,
  358.                         Child, RectangleObject, TextFrame, End,
  359.                         Child, RectangleObject, TextFrame, End,
  360.                         End,
  361.                     End,
  362.                 Child, HGroup, GroupFrameT("Different Weights"),
  363.                     Child, TextObject, TextFrame, MUIA_Background, MUII_TextBack, MUIA_Text_Contents, "\33c25 kg" ,  MUIA_Weight,  25, End,
  364.                     Child, TextObject, TextFrame, MUIA_Background, MUII_TextBack, MUIA_Text_Contents, "\33c50 kg" ,  MUIA_Weight,  50, End,
  365.                     Child, TextObject, TextFrame, MUIA_Background, MUII_TextBack, MUIA_Text_Contents, "\33c75 kg" ,  MUIA_Weight,  75, End,
  366.                     Child, TextObject, TextFrame, MUIA_Background, MUII_TextBack, MUIA_Text_Contents, "\33c100 kg",  MUIA_Weight, 100, End,
  367.                     End,
  368.                 Child, HGroup, GroupFrameT("Fixed & Variable Sizes"),
  369.                     Child, TextObject, TextFrame, MUIA_Background, MUII_TextBack, MUIA_Text_Contents, "fixed"         ,  MUIA_Text_SetMax, TRUE , End,
  370.                     Child, TextObject, TextFrame, MUIA_Background, MUII_TextBack, MUIA_Text_Contents, "\33cfree"  ,  MUIA_Text_SetMax, FALSE, End,
  371.                     Child, TextObject, TextFrame, MUIA_Background, MUII_TextBack, MUIA_Text_Contents, "fixed"         ,  MUIA_Text_SetMax, TRUE , End,
  372.                     Child, TextObject, TextFrame, MUIA_Background, MUII_TextBack, MUIA_Text_Contents, "\33cfree"  ,  MUIA_Text_SetMax, FALSE, End,
  373.                     Child, TextObject, TextFrame, MUIA_Background, MUII_TextBack, MUIA_Text_Contents, "fixed"         ,  MUIA_Text_SetMax, TRUE , End,
  374.                     End,
  375.                 End,
  376.             End,
  377.  
  378.         SubWindow,
  379.             WI_Frames = DemoWindow("Frames",MAKE_ID('F','R','M','S'),IN_Frames),
  380.                 Child, ColGroup(2),
  381.                     Child, TextObject, ButtonFrame     , InnerSpacing(2,1), MUIA_Background, MUII_TextBack, MUIA_Text_Contents, "\33cButton"     , End,
  382.                     Child, TextObject, ImageButtonFrame, InnerSpacing(2,1), MUIA_Background, MUII_TextBack, MUIA_Text_Contents, "\33cImageButton", End,
  383.                     Child, TextObject, TextFrame       , InnerSpacing(2,1), MUIA_Background, MUII_TextBack, MUIA_Text_Contents, "\33cText"       , End,
  384.                     Child, TextObject, StringFrame     , InnerSpacing(2,1), MUIA_Background, MUII_TextBack, MUIA_Text_Contents, "\33cString"     , End,
  385.                     Child, TextObject, ReadListFrame   , InnerSpacing(2,1), MUIA_Background, MUII_TextBack, MUIA_Text_Contents, "\33cReadList"   , End,
  386.                     Child, TextObject, InputListFrame  , InnerSpacing(2,1), MUIA_Background, MUII_TextBack, MUIA_Text_Contents, "\33cInputList"  , End,
  387.                     Child, TextObject, PropFrame       , InnerSpacing(2,1), MUIA_Background, MUII_TextBack, MUIA_Text_Contents, "\33cProp Gadget", End,
  388.                     Child, TextObject, GroupFrame      , InnerSpacing(2,1), MUIA_Background, MUII_TextBack, MUIA_Text_Contents, "\33cGroup"      , End,
  389.                     End,
  390.                 End,
  391.             End,
  392.  
  393.         SubWindow,
  394.             WI_Images = DemoWindow("Images",MAKE_ID('I','M','G','S'),IN_Images),
  395.                 Child, HGroup,
  396.                     Child, ColGroup(2), GroupFrameT("Some Images"),
  397.                         Child, Label("ArrowUp:"    ), Child, Image(MUII_ArrowUp    ),
  398.                         Child, Label("ArrowDown:"  ), Child, Image(MUII_ArrowDown  ),
  399.                         Child, Label("ArrowLeft:"  ), Child, Image(MUII_ArrowLeft  ),
  400.                         Child, Label("ArrowRight:" ), Child, Image(MUII_ArrowRight ),
  401.                         Child, Label("RadioButton:"), Child, Image(MUII_RadioButton),
  402.                         Child, Label("File:"       ), Child, Image(MUII_PopFile    ),
  403.                         Child, Label("HardDisk:"   ), Child, Image(MUII_HardDisk   ),
  404.                         Child, Label("Disk:"       ), Child, Image(MUII_Disk       ),
  405.                         Child, Label("Chip:"       ), Child, Image(MUII_Chip       ),
  406.                         Child, Label("Drawer:"     ), Child, Image(MUII_Drawer     ),
  407.                         End,
  408.                     Child, VGroup, GroupFrameT("Scale Engine"),
  409.                         Child, VSpace(0),
  410.                         Child, HGroup,
  411.                             Child, ScaledImage(MUII_RadioButton,1,17, 9),
  412.                             Child, ScaledImage(MUII_RadioButton,1,20,12),
  413.                             Child, ScaledImage(MUII_RadioButton,1,23,15),
  414.                             Child, ScaledImage(MUII_RadioButton,1,26,18),
  415.                             Child, ScaledImage(MUII_RadioButton,1,29,21),
  416.                             End,
  417.                         Child, VSpace(0),
  418.                         Child, HGroup,
  419.                             Child, ScaledImage(MUII_CheckMark,1,13, 7),
  420.                             Child, ScaledImage(MUII_CheckMark,1,16,10),
  421.                             Child, ScaledImage(MUII_CheckMark,1,19,13),
  422.                             Child, ScaledImage(MUII_CheckMark,1,22,16),
  423.                             Child, ScaledImage(MUII_CheckMark,1,25,19),
  424.                             Child, ScaledImage(MUII_CheckMark,1,28,22),
  425.                             End,
  426.                         Child, VSpace(0),
  427.                         Child, HGroup,
  428.                             Child, ScaledImage(MUII_PopFile,0,12,10),
  429.                             Child, ScaledImage(MUII_PopFile,0,15,13),
  430.                             Child, ScaledImage(MUII_PopFile,0,18,16),
  431.                             Child, ScaledImage(MUII_PopFile,0,21,19),
  432.                             Child, ScaledImage(MUII_PopFile,0,24,22),
  433.                             Child, ScaledImage(MUII_PopFile,0,27,25),
  434.                             End,
  435.                         Child, VSpace(0),
  436.                         End,
  437.                     End,
  438.                 End,
  439.             End,
  440.  
  441.         SubWindow,
  442.             WI_Master = WindowObject,
  443.             MUIA_Window_Title, "MUI-Demo",
  444.             MUIA_Window_ID   , MAKE_ID('M','A','I','N'),
  445.             WindowContents, VGroup,
  446.                 Child, TextObject, GroupFrame, MUIA_Background, MUII_SHADOWFILL, MUIA_Text_Contents, "\33c\0338MUI - \33bM\33nagic\33bU\33nser\33bI\33nnterface\nwritten 1992-95 by Stefan Stuntz",  End,
  447.  
  448.                 Child, List(IN_Master),
  449.  
  450.                 Child, VGroup, GroupFrameT("Available Demos"),
  451.                     Child, HGroup, MUIA_Group_SameWidth, TRUE,
  452.                         Child, BT_Groups    = SimpleButton("_Groups"),
  453.                         Child, BT_Frames    = SimpleButton("_Frames"),
  454.                         Child, BT_Backfill  = SimpleButton("_Backfill"),
  455.                         End,
  456.                     Child, HGroup, MUIA_Group_SameWidth, TRUE,
  457.                         Child, BT_Notify    = SimpleButton("_Notify"),
  458.                         Child, BT_Listviews = SimpleButton("_Listviews"),
  459.                         Child, BT_Cycle     = SimpleButton("_Cycle"),
  460.                         End,
  461.                     Child, HGroup, MUIA_Group_SameWidth, TRUE,
  462.                         Child, BT_Images    = SimpleButton("_Images" ),
  463.                         Child, BT_String    = SimpleButton("_Strings"),
  464.                         Child, BT_Quit      = SimpleButton("_Quit"   ),
  465.                         End,
  466.                     End,
  467.                 End,
  468.             End,
  469.  
  470.         End;
  471.  
  472.  
  473. /*
  474. ** See if the application was created. The fail function
  475. ** is defined in demos.h, it deletes every created object
  476. ** and closes "muimaster.library".
  477. **
  478. ** Note that we do not need any
  479. ** error control for the sub objects since every error
  480. ** will automatically be forwarded to the parent object
  481. ** and cause this one to fail too.
  482. */
  483.  
  484.     if (!AP_Demo) fail(AP_Demo,"Failed to create application.");
  485.  
  486.  
  487.  
  488. /*
  489. ** Here comes the notifcation magic. Notifying means:
  490. ** When an attribute of an object changes, then please change
  491. ** another attribute of another object (accordingly) or send
  492. ** a method to another object.
  493. */
  494.  
  495. /*
  496. ** Lets bind the sub windows to the corresponding button
  497. ** of the master window.
  498. */
  499.  
  500.     DoMethod(BT_Frames   ,MUIM_Notify,MUIA_Pressed,FALSE,WI_Frames   ,3,MUIM_Set,MUIA_Window_Open,TRUE);
  501.     DoMethod(BT_Images   ,MUIM_Notify,MUIA_Pressed,FALSE,WI_Images   ,3,MUIM_Set,MUIA_Window_Open,TRUE);
  502.     DoMethod(BT_Notify   ,MUIM_Notify,MUIA_Pressed,FALSE,WI_Notify   ,3,MUIM_Set,MUIA_Window_Open,TRUE);
  503.     DoMethod(BT_Listviews,MUIM_Notify,MUIA_Pressed,FALSE,WI_Listviews,3,MUIM_Set,MUIA_Window_Open,TRUE);
  504.     DoMethod(BT_Groups   ,MUIM_Notify,MUIA_Pressed,FALSE,WI_Groups   ,3,MUIM_Set,MUIA_Window_Open,TRUE);
  505.     DoMethod(BT_Backfill ,MUIM_Notify,MUIA_Pressed,FALSE,WI_Backfill ,3,MUIM_Set,MUIA_Window_Open,TRUE);
  506.     DoMethod(BT_Cycle    ,MUIM_Notify,MUIA_Pressed,FALSE,WI_Cycle    ,3,MUIM_Set,MUIA_Window_Open,TRUE);
  507.     DoMethod(BT_String   ,MUIM_Notify,MUIA_Pressed,FALSE,WI_String   ,3,MUIM_Set,MUIA_Window_Open,TRUE);
  508.  
  509.     DoMethod(BT_Quit     ,MUIM_Notify,MUIA_Pressed,FALSE,AP_Demo,2,MUIM_Application_ReturnID,MUIV_Application_ReturnID_Quit);
  510.  
  511.  
  512. /*
  513. ** Automagically remove a window when the user hits the close gadget.
  514. */
  515.  
  516.     DoMethod(WI_Images   ,MUIM_Notify,MUIA_Window_CloseRequest,TRUE,WI_Images   ,3,MUIM_Set,MUIA_Window_Open,FALSE);
  517.     DoMethod(WI_Frames   ,MUIM_Notify,MUIA_Window_CloseRequest,TRUE,WI_Frames   ,3,MUIM_Set,MUIA_Window_Open,FALSE);
  518.     DoMethod(WI_Notify   ,MUIM_Notify,MUIA_Window_CloseRequest,TRUE,WI_Notify   ,3,MUIM_Set,MUIA_Window_Open,FALSE);
  519.     DoMethod(WI_Listviews,MUIM_Notify,MUIA_Window_CloseRequest,TRUE,WI_Listviews,3,MUIM_Set,MUIA_Window_Open,FALSE);
  520.     DoMethod(WI_Groups   ,MUIM_Notify,MUIA_Window_CloseRequest,TRUE,WI_Groups   ,3,MUIM_Set,MUIA_Window_Open,FALSE);
  521.     DoMethod(WI_Backfill ,MUIM_Notify,MUIA_Window_CloseRequest,TRUE,WI_Backfill ,3,MUIM_Set,MUIA_Window_Open,FALSE);
  522.     DoMethod(WI_Cycle    ,MUIM_Notify,MUIA_Window_CloseRequest,TRUE,WI_Cycle    ,3,MUIM_Set,MUIA_Window_Open,FALSE);
  523.     DoMethod(WI_String   ,MUIM_Notify,MUIA_Window_CloseRequest,TRUE,WI_String   ,3,MUIM_Set,MUIA_Window_Open,FALSE);
  524.  
  525.  
  526. /*
  527. ** Closing the master window forces a complete shutdown of the application.
  528. */
  529.  
  530.     DoMethod(WI_Master,MUIM_Notify,MUIA_Window_CloseRequest,TRUE,AP_Demo,2,MUIM_Application_ReturnID,MUIV_Application_ReturnID_Quit);
  531.  
  532.  
  533. /*
  534. ** This connects the prop gadgets in the notification demo window.
  535. */
  536.  
  537.     DoMethod(PR_PropA,MUIM_Notify,MUIA_Prop_First,MUIV_EveryTime,PR_PropH,3,MUIM_Set,MUIA_Prop_First,MUIV_TriggerValue);
  538.     DoMethod(PR_PropA,MUIM_Notify,MUIA_Prop_First,MUIV_EveryTime,PR_PropV,3,MUIM_Set,MUIA_Prop_First,MUIV_TriggerValue);
  539.     DoMethod(PR_PropH,MUIM_Notify,MUIA_Prop_First,MUIV_EveryTime,PR_PropL,3,MUIM_Set,MUIA_Prop_First,MUIV_TriggerValue);
  540.     DoMethod(PR_PropH,MUIM_Notify,MUIA_Prop_First,MUIV_EveryTime,PR_PropR,3,MUIM_Set,MUIA_Prop_First,MUIV_TriggerValue);
  541.     DoMethod(PR_PropV,MUIM_Notify,MUIA_Prop_First,MUIV_EveryTime,PR_PropT,3,MUIM_Set,MUIA_Prop_First,MUIV_TriggerValue);
  542.     DoMethod(PR_PropV,MUIM_Notify,MUIA_Prop_First,MUIV_EveryTime,PR_PropB,3,MUIM_Set,MUIA_Prop_First,MUIV_TriggerValue);
  543.  
  544.     DoMethod(PR_PropA ,MUIM_Notify,MUIA_Prop_First   ,MUIV_EveryTime,GA_Gauge2,3,MUIM_Set,MUIA_Gauge_Current,MUIV_TriggerValue);
  545.     DoMethod(GA_Gauge2,MUIM_Notify,MUIA_Gauge_Current,MUIV_EveryTime,GA_Gauge1,3,MUIM_Set,MUIA_Gauge_Current,MUIV_TriggerValue);
  546.     DoMethod(GA_Gauge2,MUIM_Notify,MUIA_Gauge_Current,MUIV_EveryTime,GA_Gauge3,3,MUIM_Set,MUIA_Gauge_Current,MUIV_TriggerValue);
  547.  
  548.  
  549. /*
  550. ** And here we connect cycle gadgets, radio buttons and the list in the
  551. ** cycle & radio window.
  552. */
  553.  
  554.     DoMethod(CY_Computer,MUIM_Notify,MUIA_Cycle_Active,MUIV_EveryTime,MT_Computer,3,MUIM_Set,MUIA_Radio_Active,MUIV_TriggerValue);
  555.     DoMethod(CY_Printer ,MUIM_Notify,MUIA_Cycle_Active,MUIV_EveryTime,MT_Printer ,3,MUIM_Set,MUIA_Radio_Active,MUIV_TriggerValue);
  556.     DoMethod(CY_Display ,MUIM_Notify,MUIA_Cycle_Active,MUIV_EveryTime,MT_Display ,3,MUIM_Set,MUIA_Radio_Active,MUIV_TriggerValue);
  557.     DoMethod(MT_Computer,MUIM_Notify,MUIA_Radio_Active,MUIV_EveryTime,CY_Computer,3,MUIM_Set,MUIA_Cycle_Active,MUIV_TriggerValue);
  558.     DoMethod(MT_Printer ,MUIM_Notify,MUIA_Radio_Active,MUIV_EveryTime,CY_Printer ,3,MUIM_Set,MUIA_Cycle_Active,MUIV_TriggerValue);
  559.     DoMethod(MT_Display ,MUIM_Notify,MUIA_Radio_Active,MUIV_EveryTime,CY_Display ,3,MUIM_Set,MUIA_Cycle_Active,MUIV_TriggerValue);
  560.     DoMethod(MT_Computer,MUIM_Notify,MUIA_Radio_Active,MUIV_EveryTime,LV_Computer,3,MUIM_Set,MUIA_List_Active ,MUIV_TriggerValue);
  561.     DoMethod(LV_Computer,MUIM_Notify,MUIA_List_Active ,MUIV_EveryTime,MT_Computer,3,MUIM_Set,MUIA_Radio_Active,MUIV_TriggerValue);
  562.  
  563.  
  564. /*
  565. ** This one makes us receive input ids from several list views.
  566. */
  567.  
  568.     DoMethod(LV_Volumes ,MUIM_Notify,MUIA_Listview_DoubleClick,TRUE,AP_Demo,2,MUIM_Application_ReturnID,ID_NEWVOL);
  569.     DoMethod(LV_Brian   ,MUIM_Notify,MUIA_List_Active,MUIV_EveryTime,AP_Demo,2,MUIM_Application_ReturnID,ID_NEWBRI);
  570.  
  571.  
  572. /*
  573. ** Now lets set the TAB cycle chain for some of our windows.
  574. */
  575.  
  576.     DoMethod(WI_Master   ,MUIM_Window_SetCycleChain,BT_Groups,BT_Frames,BT_Backfill,BT_Notify,BT_Listviews,BT_Cycle,BT_Images,BT_String,NULL);
  577.     DoMethod(WI_Listviews,MUIM_Window_SetCycleChain,LV_Directory,LV_Volumes,NULL);
  578.     DoMethod(WI_Cycle    ,MUIM_Window_SetCycleChain,MT_Computer,MT_Printer,MT_Display,CY_Computer,CY_Printer,CY_Display,LV_Computer,NULL);
  579.     DoMethod(WI_String   ,MUIM_Window_SetCycleChain,ST_Brian,NULL);
  580.  
  581.  
  582. /*
  583. ** Set some start values for certain objects.
  584. */
  585.  
  586.     DoMethod(LV_Computer,MUIM_List_Insert,CYA_Computer,-1,MUIV_List_Insert_Bottom);
  587.     DoMethod(LV_Brian   ,MUIM_List_Insert,LVT_Brian,-1,MUIV_List_Insert_Bottom);
  588.     set(LV_Computer,MUIA_List_Active,0);
  589.     set(LV_Brian   ,MUIA_List_Active,0);
  590.     set(ST_Brian   ,MUIA_String_AttachedList,LV_Brian);
  591.  
  592.  
  593. /*
  594. ** Everything's ready, lets launch the application. We will
  595. ** open the master window now.
  596. */
  597.  
  598.     set(WI_Master,MUIA_Window_Open,TRUE);
  599.  
  600.  
  601. /*
  602. ** This is the main loop. As you can see, it does just nothing.
  603. ** Everything is handled by MUI, no work for the programmer.
  604. **
  605. ** The only thing we do here is to react on a double click
  606. ** in the volume list (which causes an ID_NEWVOL) by setting
  607. ** a new directory name for the directory list. If you want
  608. ** to see a real file requester with MUI, wait for the
  609. ** next release of MFR :-)
  610. */
  611.  
  612.     {
  613.         ULONG signal;
  614.         BOOL running = TRUE;
  615.         char *buf;
  616.  
  617.         while (running)
  618.         {
  619.             switch (DoMethod(AP_Demo,MUIM_Application_Input,&signal))
  620.             {
  621.                 case MUIV_Application_ReturnID_Quit:
  622.                     running = FALSE;
  623.                     break;
  624.  
  625.                 case ID_NEWVOL:
  626.                     DoMethod(LV_Volumes,MUIM_List_GetEntry,MUIV_List_GetEntry_Active,&buf);
  627.                     set(LV_Directory,MUIA_Dirlist_Directory,buf);
  628.                     break;
  629.  
  630.                 case ID_NEWBRI:
  631.                     get(LV_Brian,MUIA_List_Active,&buf);
  632.                     set(ST_Brian,MUIA_String_Contents,LVT_Brian[(int)buf]);
  633.                     break;
  634.  
  635.                 case ID_ABOUT:
  636.                     MUI_Request(AP_Demo, WI_Master, 0, NULL, "OK", "MUI-Demo\n© 1992-95 by Stefan Stuntz");
  637.                     break;
  638.             }
  639.             if (running && signal) Wait(signal);
  640.         }
  641.     }
  642.  
  643.  
  644.  
  645. /*
  646. ** Call the fail function in demos.h, this will dispose the
  647. ** application object and close "muimaster.library".
  648. */
  649.  
  650.     fail(AP_Demo,NULL);
  651. }
  652.  
  653.  
  654. /*
  655. ** This is the end...
  656. */
  657.